<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:63:"D:\wamp\www\tp5\public/../application/index\view\Cart\cart.html";i:1528022907;}*/ ?>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>购物车页</title>
	 <link href="/static/home/AmazeUI-2.4.2/assets/css/amazeui.css" rel="stylesheet" type="text/css" />
		<link href="/static/home/basic/css/demo.css" rel="stylesheet" type="text/css" />
		<link href="/static/home/css/cartstyle.css" rel="stylesheet" type="text/css" />
		<link href="/static/home/css/optstyle.css" rel="stylesheet" type="text/css" />

		<script type="text/javascript" src="/static/home/js/jquery.js"></script>
</head>
<body>
	  <!--顶部导航条 -->
		<div class="am-container header">
			<ul class="message-r">
				<div class="topMessage home">
					<div class="menu-hd"><a href="#" target="_top" class="h">商城首页</a></div>
				</div>
				<div class="topMessage my-shangcheng">
					<div class="menu-hd MyShangcheng"><a href="#" target="_top"><i class="am-icon-user am-icon-fw"></i>个人中心</a></div>
				</div>
				<div class="topMessage mini-cart">
					<div class="menu-hd"><a id="mc-menu-hd" href="#" target="_top"><i class="am-icon-shopping-cart  am-icon-fw"></i><span>购物车</span><strong id="J_MiniCartNum" class="h">0</strong></a></div>
				</div>
				<div class="topMessage favorite">
					<div class="menu-hd"><a href="#" target="_top"><i class="am-icon-heart am-icon-fw"></i><span>收藏夹</span></a></div>
			</ul>
			</div>

			<!--悬浮搜索框-->

			<div class="nav white">
				<div class="logoBig" style="position:relative;top:-15px;right:120px;"> 
			     <li><img src="/static/home/images/aishang.png" /></li> 
			    </div> 
				<div class="search-bar pr">
					<a name="index_none_header_sysc" href="#"></a>
					<form action="/home/goods" method="post"> 
				      <input id="searchInput" name="search" type="text" placeholder="搜索" autocomplete="off" /> 
				      <input id="ai-topsearch" class="submit am-btn" value="搜索" index="1" type="submit" /> 
				     </form> 
				</div>
			</div>

			<div class="clear"></div>
            <b class="line"></b>
			<div class="listMain">

				<!--分类-->
			<div class="nav-table">
					   <div class="long-title"><span class="all-goods">全部分类</span></div>
					   <div class="nav-cont">
							<ul>
								<li class="index"><a href="/home/index">首页</a></li>
                               <?php if(is_array($brand) || $brand instanceof \think\Collection || $brand instanceof \think\Paginator): if( count($brand)==0 ) : echo "" ;else: foreach($brand as $key=>$bra): ?>
      								<li class="qc"><a href="/home/brand/id/<?php echo $bra['id']; ?>"><?php echo $bra['brand']; ?></a></li>
  								<?php endforeach; endif; else: echo "" ;endif; ?>
							</ul>
						    <div class="nav-extra">
						    	<i class="am-icon-user-secret am-icon-md nav-user"></i><b></b>我的福利
						    	<i class="am-icon-angle-right" style="padding-left: 10px;"></i>
						    </div>
						</div>
			</div>
			<br>
				<ol class="am-breadcrumb am-breadcrumb-slash">
					<li><a href="#">首页</a></li>
					<li><a href="#">分类</a></li>
					<li class="am-active">购物车</li>
				</ol>
				<script type="text/javascript">
					// $(function() {});
					// $(window).load(function() {
					// 	$('.flexslider').flexslider({
					// 		animation: "slide",
					// 		start: function(slider) {
					// 			$('body').removeClass('loading');
					// 		}
					// 	});
					// });
				</script>
			

				<!--购物车 -->
			<div class="concent">
				<div id="cartTable">
					<div class="cart-table-th">
						<div class="wp">
							<div class="th th-chk">
								<div id="J_SelectAll1" class="select-all J_SelectAll">

								</div>
							</div>
							<div class="th th-item">
								<div class="td-inner">商品信息</div>
							</div>
							<div class="th th-price">
								<div class="td-inner">单价</div>
							</div>
							<div class="th th-amount">
								<div class="td-inner">数量</div>
							</div>
							<div class="th th-sum">
								<div class="td-inner">金额</div>
							</div>
							<div class="th th-op">
								<div class="td-inner">操作</div>
							</div>
						</div>
					</div>
					<div class="clear"></div>

					<div class="clear"></div>



				</div>
				
					
					<?php if((!empty($_SESSION['cart']))): ?>
					<table id="ss">
					<?php if(is_array($cart) || $cart instanceof \think\Collection || $cart instanceof \think\Paginator): if( count($cart)==0 ) : echo "" ;else: foreach($cart as $key=>$row): ?>
						<div class="bundle  bundle-last ">
							<div class="bundle-hd">
								<div class="bd-promos">
									<div class="bd-has-promo"><span class="bd-has-promo-content"></span>&nbsp;&nbsp;</div>
									<div class="act-promo">
										<a href="#" target="_blank"><span class="gt"></span></a>
									</div>
									<span class="list-change theme-login">编辑</span>
								</div>
							</div>
							<div class="clear"></div>
							<div class="bundle-main">
								<ul class="item-content clearfix">
									<li class="td td-chk">
										<div class="dad">
											<input type="checkbox" value="<?php echo $row['id']; ?>" class="check">
											<label for="J_CheckBox_170769542747"></label>
										</div>
									</li>
									<li class="td td-item">
										<div class="item-pic">
											<a href="#" target="_blank" data-title="美康粉黛醉美东方唇膏口红正品 持久保湿滋润防水不掉色护唇彩妆" class="J_MakePoint" data-point="tbcart.8.12">
												<img src="/uploads/<?php echo $row['pic']; ?>" class="itempic J_ItemImg"></a>
										</div>
										<div class="item-info">
											<div class="item-basic-info">
												<a href="#" target="_blank" title="美康粉黛醉美唇膏 持久保湿滋润防水不掉色" class="item-title J_MakePoint" data-point="tbcart.8.11"><?php echo $row['name']; ?></a>
											</div>
										</div>
									</li>
									<li class="td td-info">
										<div class="item-props item-props-can">
											
											<span class="sku-line">包装：两支手袋装（送彩带）</span>
											<span tabindex="0" class="btn-edit-sku theme-login">修改</span>
											<i class="theme-login am-icon-sort-desc"></i>
										</div>
									</li>
									<li class="td td-price">
										<div class="item-price price-promo-promo">
											<div class="price-content">
												<div class="price-line">
													
												</div>
												<div class="price-line">
													<span class="J_Price price-now" tabindex="0"><?php echo $row['price']; ?></span>
												</div>
											</div>
										</div>
									</li>
									<li class="td td-amount">
										<div class="amount-wrapper ">
											<div class="item-amount ">
												<div class="sl">
													<input class="jian am-btn" type="button" name="<?php echo $row['id']; ?>"  value="-" />
													<input class="text_box" name="" type="text" value="<?php echo $row['num']; ?>" style="width:30px;" />
													<input class="jia am-btn" name="<?php echo $row['id']; ?>" type="button" value="+" />
												</div>
											</div>
										</div>
									</li>
									<li class="td td-sum">
										<div class="td-inner">
											<?php echo $row['num']*$row['price']; ?>
								
										</div>
									</li>
									<li class="td td-op">
										<div class="td-inner">
											<a title="移入收藏夹" class="btn-fav" href="#">
                  移入收藏夹</a>
											<a href="javascript:void(0)" data-point-url="#" class="del" name="<?php echo $row['id']; ?>">
                  删除</a>
										</div>
									</li>
								</ul>
							</div>
						</div>

					<?php endforeach; endif; else: echo "" ;endif; ?>
		
					
					</table>
				
					<div class="clear"></div>

				<div class="float-bar-wrapper" id="ddd">
					<div class="operations">
						<a href="javascript:void(0)" hidefocus="true" class="allchoose">全选</a>
						<a href="javascript:void(0)" hidefocus="true" class="fchoose">反选</a>
					</div>

					<div class="operations">
						<a href="javascript:void(0)" hidefocus="true" class="delete" name="">删除</a>
						<a href="javascript:void(0)" hidefocus="true" class="J_BatchFav">移入收藏夹</a>
					</div>
					<div class="float-bar-right">
						<div class="amount-sum">
							<span>已选商品</span>&nbsp;&nbsp;&nbsp;<span class="txt1">0</span>
							<em id="two"></em><span class="txt">件</span>
							<div class="arrow-box">
								<span class="selected-items-arrow"></span>
								<span class="arrow"></span>
							</div>
						</div>
						<div class="price-sum">
							<span class="txt">合计:</span>
							<strong class="price">¥<em id="J_Total" class="txt2" style="position:relative; top:-2px;">0</em></strong>
						</div>

						<div class="btn-area">
							<a href="/pay/index" id="J_Go" class="submit-btn submit-btn-disabled" aria-label="请注意如果没有选择宝贝，将无法结算">
								<span class="jiesuan">结&nbsp;算</span></a>
						</div>
					</div>
					<?php else: ?>
					
						<center>没有商品请去购物</center>
					
					<?php endif; ?>
				</div>

			</div>
			<div class="kong" style="font-size:16px; text-align:center;"></div>
	<?php echo widget("Cate/footer"); ?>
</body>
 <script type="text/javascript">
	 $(".jian").click(function(){
	 	id=$(this).attr("name");
    	ob=$(this);
    	//ajax传递id参数
    	$.get("/cart/jian",{id:id},function(data){
    		//赋值数量
    		ob.next("input").val(data.num);
    		//赋值总价
    		ob.parents("li").next("li").find("div").html(data.tot);
    	},'json')

    	// alert(id);
	 })

	 $(".jia").click(function(){
	 	id=$(this).attr("name");
    	ob=$(this);
    	//ajax
    	$.get("/cart/jia",{id:id},function(data){
    		//赋值数量
    		ob.prev("input").val(data.num);
    		//赋值总价
    		ob.parents("li").next("li").find("div").html(data.tot);
    	},'json');
	 })

	 //删除
	 $(".del").click(function(){
	 	//获取id
	 	id=$(this).attr("name");
    	ob=$(this);
    	//ajax
    	$.get("/cart/del",{id:id},function(data){
    		if(data==1){
    			ob.parent().parent().parent().parent().parent().remove();
    		}else{
    			ob.parent().parent().parent().parent().parent().remove();
    			$("#ddd").remove();
    			kong=$(".kong");
    			kong.html("请选择商品");

    		}
    	});
	 })


	 //全选
	 $(".allchoose").click(function(){
	 	
	 	$(".dad").each(function(){
	 		$(this).find(":checkbox").attr("checked",true);
	 	});

			arr2=[];
	 		$(":checkbox").each(function(){
	 		//判断
	 		if($(this).attr("checked")){
	 			//获取id
	 			id=$(this).val();
	 			//把选中数据的id存在数组中
	 			arr2.push(id);
	 		}
	 	});	
	 	 $.get("/cart/quanjia",{arr2:arr2},function(data){
	 	 		$(".txt1").html(data.gnum1);
	 			$(".txt2").html(data.allprice1);
	 	 },'json');	
	 		// console.log(arr2);
	 })

	 //反选
	 $(".fchoose").click(function(){
	 	$(".dad").each(function(){
	 		if($(this).find(":checkbox").attr("checked")){
	 			 //设置为不选中
        		$(this).find(":checkbox").attr("checked",false);
	 		}else{
	 			 //设置为不选中
        		$(this).find(":checkbox").attr("checked",true);
	 		}
	 	})

	 		arr3=[];
	 		$(":checkbox").each(function(){
	 		//判断
	 		if($(this).attr("checked")){
	 			//获取id
	 			id=$(this).val();
	 			//把选中数据的id存在数组中
	 			arr3.push(id);
	 		}
	 	});
	 	 $.get("/cart/fanjia",{arr3:arr3},function(data){
	 	 		if(data==0){
	 	 			$(".txt1").html(0);
	 				$(".txt2").html(0);
	 	 		}else{
	 	 			$(".txt1").html(data.gnum2);
	 				$(".txt2").html(data.allprice2);	
	 	 		}
	 	 		
	 	 },'json');		

	 })

	 //选中删除
	 $(".delete").click(function(){
	 	arr=[];
	 	//获取选中数据id
	 	//遍历所有的复选框
	 	$(":checkbox").each(function(){
	 		//判断
	 		if($(this).attr("checked")){
	 			//获取id
	 			id=$(this).val();
	 			//把选中数据的id存在数组中
	 			arr.push(id);
	 		}
	 	});

	 	// alert(arr);
	 	//ajax
	 	$.get("/cart/dels",{arr:arr},function(data){
	 		if(data==1){
	 			alert("删除成功");
	 			//删除数据
	 			//遍历arr
	 			for(var i=0;i<arr.length;i++){
	 				$("input[value="+arr[i]+"]").parent().parent().parent().parent().parent().remove();
	 			}
	 		}else{
	 			alert('删除成功2');
	 			for(var i=0;i<arr.length;i++){
	 				$("input[value="+arr[i]+"]").parent().parent().parent().parent().parent().remove();
	 			}
	 			$("#ddd").remove();
    			kong=$(".kong");
    			kong.html("请选择商品");
	 		}

	 	});

	 })
	 //选中后总价数量
	 $(".check").click(function(){
	 	
	 		arr=[];
	 		$(":checkbox").each(function(){
	 		//判断
	 		if($(this).attr("checked")){
	 			//获取id
	 			id=$(this).val();
	 			//把选中数据的id存在数组中
	 			arr.push(id);
	 		}
	 	});	

	 		// alert(arr);
	 		// console.log(arr);
	 		$.get("/cart/xuan",{arr:arr},function(data){
	 				if(data==0){
	 					$(".txt1").html(0);
	 					$(".txt2").html(0);
	 				}else{
	 					$(".txt1").html(data.gnum);
	 					$(".txt2").html(data.allprice);
	 				}
	 			
	 				
	 				// console.log(data);
	 			},'json')
	 		// alert(data);

	 });
	 //选中后增加session['oreder'];
	
	  $(".jiesuan").click(function(){
	  		arr1=[];
	 		$(":checkbox").each(function(){
	 		//判断
	 		if($(this).attr("checked")){
	 			//获取id
	 			id=$(this).val();
	 			//把选中数据的id存在数组中
	 			arr1.push(id);
	 		}
	 	});
	 		// console.log(arr1);
	 		$.get("/cart/order",{arr1:arr1},function(data){
	 			if(data==0){
	 				window.location.href="/cart/error";
	 			}
	 		})
	 		
	  })

	  //选中增减数量查询
	   $(".check").click(function(){
	   		ob=$(this);
	   		oc=ob.parents("ul").find("li:eq(4)").find("div:eq(2)").find("input:eq(2)");
	   		oc.click(function(){
	   			//因为已经数量做了加减所以只需传递回去选中的数量和价格
	   			//获取input框选中的id
	   			arr5=[];
	 			$(":checkbox").each(function(){
	 			//判断
	 			if($(this).attr("checked")){
	 			//获取id
	 			id=$(this).val();
	 			//把选中数据的id存在数组中
	 			arr5.push(id);

	 		}
	 	});
	 			$.get("/cart/chaxun",{arr5:arr5},function(data){
	 					if(data==0){
	 					$(".txt1").html(0);
	 					$(".txt2").html(0);
	 				}else{
	 					$(".txt1").html(data.gnum2);
	 					$(".txt2").html(data.allprice2);
	 				}
	 			},'json');
	 });

  });

	    $(".check").click(function(){
	   		ob=$(this);
	   		oc=ob.parents("ul").find("li:eq(4)").find("div:eq(2)").find("input:eq(0)");
	   		oc.click(function(){
	   			//因为已经数量做了加减所以只需传递回去选中的数量和价格
	   			//获取input框选中的id
	   			arr5=[];
	 			$(":checkbox").each(function(){
	 			//判断
	 			if($(this).attr("checked")){
	 			//获取id
	 			id=$(this).val();
	 			//把选中数据的id存在数组中
	 			arr5.push(id);

	 		}
	 	});
	 			$.get("/cart/chaxun",{arr5:arr5},function(data){
	 					if(data==0){
	 					$(".txt1").html(0);
	 					$(".txt2").html(0);
	 				}else{
	 					$(".txt1").html(data.gnum2);
	 					$(".txt2").html(data.allprice2);
	 				}
	 			},'json');
	 });

  });

		//全选后加减查询
		 $(".allchoose").click(function(){
		 	$(".jia").click(function(){
		 		// alert(1);
		 		arr6=[];
	 			$(":checkbox").each(function(){
	 			//判断
	 			if($(this).attr("checked")){
	 			//获取id
	 			id=$(this).val();
	 			//把选中数据的id存在数组中
	 			arr6.push(id);

	 			}
	 		});
	 		// console.log(arr6);
	 		$.get("/cart/quanchaxun",{arr6:arr6},function(data){
	 					if(data==0){
	 					$(".txt1").html(0);
	 					$(".txt2").html(0);
	 				}else{
	 					$(".txt1").html(data.gnum3);
	 					$(".txt2").html(data.allprice3);
	 				}
	 			},'json');
		})
	})

		  $(".allchoose").click(function(){
		 	$(".jian").click(function(){
		 		// alert(1);
		 		arr6=[];
	 			$(":checkbox").each(function(){
	 			//判断
	 			if($(this).attr("checked")){
	 			//获取id
	 			id=$(this).val();
	 			//把选中数据的id存在数组中
	 			arr6.push(id);

	 			}
	 		});
	 		// console.log(arr6);
	 		$.get("/cart/quanchaxun",{arr6:arr6},function(data){
	 					if(data==0){
	 					$(".txt1").html(0);
	 					$(".txt2").html(0);
	 				}else{
	 					$(".txt1").html(data.gnum3);
	 					$(".txt2").html(data.allprice3);
	 				}
	 			},'json');
		})
	})

		//反选后数量加减
		 $(".fchoose").click(function(){
		 	$(".jia").click(function(){
		 		// alert(1);
		 		arr6=[];
	 			$(":checkbox").each(function(){
	 			//判断
	 			if($(this).attr("checked")){
	 			//获取id
	 			id=$(this).val();
	 			//把选中数据的id存在数组中
	 			arr6.push(id);

	 			}
	 		});
	 		// console.log(arr6);
	 		$.get("/cart/quanchaxun",{arr6:arr6},function(data){
	 					if(data==0){
	 					$(".txt1").html(0);
	 					$(".txt2").html(0);
	 				}else{
	 					$(".txt1").html(data.gnum3);
	 					$(".txt2").html(data.allprice3);
	 				}
	 			},'json');
		})
	})

		  $(".fchoose").click(function(){
		 	$(".jian").click(function(){
		 		// alert(1);
		 		arr6=[];
	 			$(":checkbox").each(function(){
	 			//判断
	 			if($(this).attr("checked")){
	 			//获取id
	 			id=$(this).val();
	 			//把选中数据的id存在数组中
	 			arr6.push(id);

	 			}
	 		});
	 		// console.log(arr6);
	 		$.get("/cart/quanchaxun",{arr6:arr6},function(data){
	 					if(data==0){
	 					$(".txt1").html(0);
	 					$(".txt2").html(0);
	 				}else{
	 					$(".txt1").html(data.gnum3);
	 					$(".txt2").html(data.allprice3);
	 				}
	 			},'json');
		})
	})
	   
</script>
</html>